﻿using System;
using System.Collections;
using System.Collections.Generic;

using System.Text;
using IBatisNet.DataAccess;
using Wolfut.MirageEE.Core.Service;
using Wolfut.MirageEE.Core.Test.Dao;
using Wolfut.MirageEE.Core.Test.Domain;

namespace Wolfut.MirageEE.Core.Test.Service
{
    public class CategoryService :BaseService
    {
        #region Private Fields

        private IProductDao productDao;
        private ICategoryDao categoryDao;
        #endregion

        #region Constructor
        private CategoryService():base()
        {
            //productDao = daoManager[typeof (IProductDao)] as IProductDao;
             categoryDao = daoManager[typeof(ICategoryDao)] as ICategoryDao;
            
        }
        private CategoryService(string context)
            : base(context)
        {
            //productDao = daoManager[typeof (IProductDao)] as IProductDao;
            categoryDao = daoManager[typeof(ICategoryDao)] as ICategoryDao;

        }
        public static CategoryService GetCategoryService(string contextName)
        {
            return new CategoryService(contextName);
        }
        public static CategoryService GetCategoryService()
        {
            return GetCategoryService("SqlMapDao");
        }
        #endregion

        #region Category
        public IList<Category> GetCategoryList()
        {
            return categoryDao.GetCategoryList();
        }

        public Category GetCategory(string categoryId)
        {
            Category category = null;

            daoManager.OpenConnection();
            category = categoryDao.GetCategory(categoryId);
            daoManager.CloseConnection();

            return category;
        }
        #endregion
    }
}
